<extend name="Public/base"/>

<block name="body">
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
	<div class="main-title">
		<h2>{$info['id']?'编辑':'新增'}属性</h2>
	</div>
	<form action="{:U()}" method="post" class="form-horizontal">
            
        <div class="form-item">
                <label class="item-label">商品类型<span class="check-tips"></span></label>
                <div class="controls">
                        <select name="type_id">
                            <volist name="type_list" id="vo">
                                <option value="{$vo['id']}">{$vo['name']}</option>
                            </volist>
                        </select>
                </div>
        </div>
            
        <div class="form-item">
            <label class="item-label">属性名称<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="name" value="{$info.name|default=''}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">属性选择方式<span class="check-tips">选择"单选/复选属性"时，可以对商品该属性设置多个值，同时还能对不同属性值指定不同的价格加价，用户购买商品时需要选定具体的属性值。</span></label>
            <div class="controls">
                <select name="field_type">
                    <volist name=":C('FIELD_TYPE')" id="vo">
                        <option value="{$vo.id}">{$vo.explain}</option>
                    </volist>
                </select>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">属性值录入方式<span class="check-tips"></span></label>
            <div class="controls">
                <select name="field_entering" id="field_entering" onchange="is_optional();">
                    <volist name=":C('FIELD_ENTERING')" id="vo">
                        <option value="{$vo.id}">{$vo.explain}</option>
                    </volist>
                </select>
            </div>
        </div>
   
        <div class="form-item" style=" <if condition="($info['id'] gt 0) AND ($info['field_entering'] eq 1)"> display: block; <else /> display: none; </if>" id="optional_value">
                <label class="item-label">可选值列表<span class="check-tips">（一行代表一个可选值，只有在录入方式选择列表选择时才需录入）</span></label>
                <div class="controls">
                        <label class="textarea input-large">
                                <textarea name="optional_value">{$info.optional_value|default=''}</textarea>
                        </label>
                </div>
        </div>
        <div class="form-item">
            <label class="item-label">排序<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-small" name="sort" value="{$info.sort|default='0'}">
            </div>
        </div>
 
        <div class="form-item">
                <label class="item-label">状态<span class="check-tips"></span></label>
                <div class="controls">
                        <select name="status">
                            <option value="1">启用</option>
                            <option value="0">禁用</option>
                        </select>
                </div>
        </div>

		<div class="form-item">
			<input type="hidden" name="id" value="{$info.id|default=''}">
			<button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
			<button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
		</div>
	</form>
</block>

<block name="script">
	<script type="text/javascript">
                Think.setValue("status", {$info.status|default=1});
                Think.setValue("field_entering", {$info.field_entering|default=0});
                Think.setValue("field_type", {$info.field_type|default=0});
                Think.setValue("type_id", {$info.type_id|default=$type_id});
		highlight_subnav('{:U('goodsTypeList')}');
   		 
                 
                function is_optional(){
                    if($("#field_entering").val()==1){
                        $("#optional_value").css('display','block'); 
                    }else{
                        $("#optional_value").css('display','none'); 
                    }
                }
                
                /* 初始化上传插件 */
                    $("#upload_picture_icon").uploadify({
                    "height"          : 30,
                    "swf"             : "__STATIC__/uploadify/uploadify.swf",
                    "fileObjName"     : "download",
                    "buttonText"      : "上传图片",
                    "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
                    "width"           : 120,
                    'removeTimeout'	  : 1,
                    'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
                    "onUploadSuccess" : uploadPictureicon,
                    'onFallback' : function() {
                        alert('未检测到兼容版本的Flash.');
                    }
                });
                    function uploadPictureicon(file, data){
                    var data = $.parseJSON(data);
                    var src = '';
                    if(data.status){
                            $("#cover_id_icon").val(data.id);
                            src = data.url || '__ROOT__' + data.path
                            $("#cover_id_icon").parent().find('.upload-img-box').html(
                                    '<div class="upload-pre-item"><img src="' + src + '"/></div>'
                            );
                    } else {
                            updateAlert(data.info);
                            setTimeout(function(){
                            $('#top-alert').find('button').click();
                            $(that).removeClass('disabled').prop('disabled',false);
                        },1500);
                    }
                }

	</script>
</block>
